// 创建购物车模块的数据及方法
function shopcartList(state=[],action={type:'',payload:null}){
    let newState = JSON.parse(JSON.stringify(state));
    switch( action.type){
        case 'ADD' :
            let idx = newState.findIndex((item)=>{
                 return item.id == action.payload.id
            })
            if( idx == -1){
                newState.push(action.payload)
            }
            return newState
        default : return state
    }   
}

export default shopcartList